﻿<!DOCTYPE html>
<html lang="">

<head>
    <meta charset="UTF-8">
    <!--edge浏览器H5兼容设置-->
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <!--360浏览器H5兼容设置-->
    <meta name="renderer" content="webkit"/>
    <title>修改个人资料</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!--导入核心文件-->
    <script src="../bootstrap3/js/holder.js"></script>
    <link href="../bootstrap3/css/bootstrap.css" rel="stylesheet" type="text/css">
    <script src="../bootstrap3/jquery-1.9.1.min.js"></script>
    <script src="../bootstrap3/js/bootstrap.js"></script>
    <!-- 字体图标 -->
    <link rel="stylesheet" href="../bootstrap3/font-awesome-4.7.0/css/font-awesome.css"/>
    <style type="text/css">
    html,body{width:100%;height:100%;}
    body{margin:0px auto;padding:0px auto;background:#abb9c4;color:#10273f}
</style>
</head>

<body>
<div class="container">
    <div class="panel-body">
        <!--修改资料表单开始-->
        <form class="form-horizontal" role="form" id="form-change-info">

			<div class="form-group">
				<label class="col-md-2 control-label">用户ID：</label>
				<div class="col-md-8">
					<input id="inp-adminId" name="adminId" type="text" class="form-control" value="用户ID" readonly="readonly">
				</div>
			</div>

			<div class="form-group">
				<label class="col-md-2 control-label">用户名：</label>
				<div class="col-md-8">
					<input id="inp-adminName" name="adminName" type="text" class="form-control" value="用户名" readonly="readonly">
				</div>
			</div>


			<div class="form-group">
				<label class="col-md-2 control-label">昵称：</label>
				<div class="col-md-8">
					<input type="text"  placeholder="请输入昵称"name="nickName" class="form-control" id="nickName"/>
				</div>
			</div>

			<div class="form-group">
				<label class="col-md-2 control-label">用户角色：</label>
				<div class="col-md-8">
					<input type="text" name="roleName" disabled placeholder="没有职务" class="form-control" id="inp-roleName" checked>
				</div>
			</div>

			<div class="form-group">
				<label class="col-md-2 control-label">角色编号：</label>
				<div class="col-md-8">
					<input type="text"  name="adminGrade" placeholder="您还没有编号" class="form-control"id="inp-adminGrade" disabled>
				</div>
			</div>

            <div class="form-group">
                <label class="col-md-2 control-label">电话号码：</label>
                <div class="col-md-8">
                    <input id="inp-phone" name="phone" type="text" class="form-control" placeholder="请输入电话号码" value="电话号码">
                </div>
            </div>
			<div class="form-group">
				<label class="col-md-2 control-label">性别：</label>
				<div class="col-md-8">
					<label class="radio-inline">
						<input id="gender-male" type="radio" name="gender" value="1" checked>男
					</label>
					<label class="radio-inline">
						<input id="gender-female" type="radio" name="gender" value="0">女
					</label>
				</div>
			</div>

			<div class="form-group">
				<label class="col-md-2 control-label">自我介绍</label>
				<div class="col-md-8">
					<textarea placeholder="请输入内容"  name="remarks"  class="form-control" id="tex-person">这个人很懒...</textarea>
				</div>
			</div>
            <div class="form-group">
                <div class="col-sm-offset-2 col-sm-10">
                    <input type="button" class="btn btn-primary" value="修改" id="btn-change-info"/>
                </div>
            </div>
        </form>
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function () {
        $.ajax({
            "url": "/admin/get_by_adminId",
            "type": "get",
            "dataType": "json",
            "success": function (json) {
                if (json.state === 2000) {
                	console.log("admin:"+json.data);
					$("#inp-adminId").val(json.data.adminId);
					$("#inp-adminName").val(json.data.adminName);
					$("#inp-phone").val(json.data.phone);
					$("#inp-roleName").val(json.data.roleName);
					$("#inp-adminGrade").val(json.data.adminGrade);
					let radio = json.data.gender === 1 ? $("#gender-male") : $("#gender-female");
					radio.prop("checked", "checked");
                } else {
                    alert("修改失败！" + json.message);
                }
            }
        });
    });
</script>
<script type="text/javascript">
    $("#btn-change-info").click(function () {
        $.ajax({
            "url": "/admin/change_info",
            "data": $("#form-change-info").serialize(),
            "type": "post",
            "dataType": "json",
            "success": function (json) {
                if (json.state === 2000) {
                    alert("修改成功！");
                } else {
                    alert("修改失败！" + json.message);
                }
            },
            "error": function () {
                alert("您的登录信息已过期！请重新登录");
                //location.href="login.html";
            }
        });
    });
</script>
</body>

</html>